//
//  RCSearchMoreCell.m
//  RocketProject
//
//  Created by Wu Chengwei on 13-7-10.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "RCSearchMoreCell.h"
#import "CommonDefines.h"
#import "UIColor-Expanded.h"
#import <QuartzCore/QuartzCore.h>
#import "NSString+NSString_Ex_.h"

#define kBGimageFile        @"image_searchAllCity_cell_bg.png"
#define kLineImageFile      @"image_line_type3.png"

@interface RCSearchMoreCategoryCell()

@property(nonatomic,retain) UIButton *titleImageButton;
@property(nonatomic,retain) UILabel *titleViewLabel;
@property(nonatomic,retain) UIView *redSelectView;
@property(nonatomic,retain) UIImageView *lineView;

@end

@implementation RCSearchMoreCategoryCell

@synthesize titleImageButton = _titleImageButton;
@synthesize titleViewLabel = _titleViewLabel;
@synthesize redSelectView = _redSelectView;
@synthesize lineView = _lineView;


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        _titleImageButton = [[UIButton alloc]initWithFrame:CGRectMake(15, 12, 15, 15)];
        _titleImageButton.backgroundColor = [UIColor clearColor];
        [self addSubview:_titleImageButton];
        
        _titleViewLabel = [[UILabel alloc]initWithFrame:CGRectMake(40, 12, 110, 15)];
        _titleViewLabel.backgroundColor = [UIColor clearColor];
        _titleViewLabel.textColor = [UIColor colorWithHex:0xff505050];
        _titleViewLabel.font = [UIFont fontWithName:kFontNameLightHeiti size:15];
        [self addSubview:_titleViewLabel];
        
        _redSelectView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 6, 39)];
        _redSelectView.backgroundColor = [UIColor colorWithHex:0xfff65006];
        [self addSubview:_redSelectView];
        
        _lineView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 39, 160, 1)];
        _lineView.backgroundColor = [UIColor clearColor];
        NSString *filePath = [[[NSBundle mainBundle]resourcePath]stringByAppendingPathComponent:kLineImageFile];
        [_lineView setImage:[UIImage imageWithContentsOfFile:filePath]];
        [self addSubview:_lineView];
        
        
    }
    return self;
}

-(void)dealloc{
    self.titleViewLabel = nil;
    self.titleImageButton = nil;
    self.redSelectView = nil;
    self.lineView = nil;
    [super dealloc];
}

-(void)setContentViewWithData:(NSString *)item isSelectedf:(BOOL)selected{
    if (selected) {
        _redSelectView.hidden = NO;
        self.contentView.backgroundColor = [UIColor colorWithHex:0xfffcf5ef];
        self.contentView.layer.contents = nil;
    }else{
        _redSelectView.hidden = YES;
        NSString *filePath = [[[NSBundle mainBundle]resourcePath]stringByAppendingPathComponent:kBGimageFile];
        UIImage *bgImage = [UIImage imageWithContentsOfFile:filePath];
        self.contentView.layer.contents = (id)bgImage.CGImage;
    }
    if (nil == item) {
        return;
    }
    if (![NSString stringIsNullOrEmpty:item]) {
        NSString *imageName = [self getImageNameWithTagName:item];
        NSString *imagePath = [[[NSBundle mainBundle]resourcePath]stringByAppendingPathComponent:imageName];
        [_titleImageButton setImage:[UIImage imageWithContentsOfFile:imagePath] forState:UIControlStateNormal];
        [_titleImageButton setImage:[UIImage imageWithContentsOfFile:imagePath] forState:UIControlStateHighlighted];
        
        _titleViewLabel.text = item;
    }
    
}

-(NSString *)getImageNameWithTagName:(NSString *)tagName{
    if (nil == tagName) {
        return nil;
    }
    NSString *imageName = nil;
    if ([tagName isEqualToString:@"吃"]) {
        imageName = @"image_searchAllCity_dinning.png";
    }else if ([tagName isEqualToString:@"娱"]){
        imageName = @"image_searchAllCity_entertainment.png";
    }else if ([tagName isEqualToString:@"住"]){
        imageName = @"image_searchAllCity_hotels.png";
    }else if ([tagName isEqualToString:@"购"]){
        imageName = @"image_searchAllCity_shopping.png";
    }else if ([tagName isEqualToString:@"商助"]){
        imageName = @"image_searchAllCity_assistant.png";
    }else if ([tagName isEqualToString:@"行"]){
        imageName = @"image_searchAllCity_drive.png";
    }else if ([tagName isEqualToString:@"游"]){
        imageName = @"image_searchAllCity_scene.png";
    }
    return imageName;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end



@interface RCSearchMoreDistrictCell()

@property(nonatomic,retain) UILabel *titleViewLabel;
@property(nonatomic,retain) UIView *redSelectView;
@property(nonatomic,retain) UIImageView *lineView;

@end

@implementation RCSearchMoreDistrictCell

@synthesize titleViewLabel = _titleViewLabel;
@synthesize redSelectView = _redSelectView;
@synthesize lineView = _lineView;


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        
        _titleViewLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 12, 120, 15)];
        _titleViewLabel.backgroundColor = [UIColor clearColor];
        _titleViewLabel.textColor = [UIColor colorWithHex:0xff505050];
        _titleViewLabel.font = [UIFont fontWithName:kFontNameLightHeiti size:15];
        [self addSubview:_titleViewLabel];
        
        _redSelectView = [[UIView alloc]initWithFrame:CGRectMake(1, 0, 6, 38)];
        _redSelectView.backgroundColor = [UIColor colorWithHex:0xfff65006];
        [self addSubview:_redSelectView];
        
        _lineView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 39, 160, 1)];
        _lineView.backgroundColor = [UIColor clearColor];
        NSString *filePath = [[[NSBundle mainBundle]resourcePath]stringByAppendingPathComponent:kLineImageFile];
        [_lineView setImage:[UIImage imageWithContentsOfFile:filePath]];
        [self addSubview:_lineView];
        
    }
    return self;
}

-(void)dealloc{
    self.titleViewLabel = nil;
    self.redSelectView = nil;
    self.lineView = nil;
    [super dealloc];
}

-(void)setContentViewWithData:(NSString *)item isSelectedf:(BOOL)selected{
    if (selected) {
        _redSelectView.hidden = NO;
        self.contentView.backgroundColor = [UIColor colorWithHex:0xfffcf5ef];
        self.contentView.layer.contents = nil;
    }else{
        _redSelectView.hidden = YES;
        NSString *filePath = [[[NSBundle mainBundle]resourcePath]stringByAppendingPathComponent:kBGimageFile];
        UIImage *bgImage = [UIImage imageWithContentsOfFile:filePath];
        self.contentView.layer.contents = (id)bgImage.CGImage;
    }
    if (nil == item) {
        return;
    }
    if (![NSString stringIsNullOrEmpty:item]) {
        
        _titleViewLabel.text = item;
    }
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end


@interface RCSearchRightCell()

@property(nonatomic,retain) UILabel *titleViewLabel;

@end

@implementation RCSearchRightCell

@synthesize titleViewLabel = _titleViewLabel;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        self.contentView.backgroundColor = [UIColor colorWithHex:0xfffcf5ef];
        _titleViewLabel = [[UILabel alloc]initWithFrame:CGRectMake(30, 15, 120, 14)];
        _titleViewLabel.backgroundColor = [UIColor clearColor];
        _titleViewLabel.textColor = [UIColor colorWithHex:0xff979797];
        _titleViewLabel.font = [UIFont fontWithName:kFontNameLightHeiti size:14];
        [self addSubview:_titleViewLabel];
        
        
    }
    return self;
}

-(void)dealloc{
    self.titleViewLabel = nil;
    [super dealloc];
}

-(void)setContentViewWithData:(RCSearchAllCityItem *)item{
    if (nil == item) {
        return;
    }
    if (![NSString stringIsNullOrEmpty:item.itemName]) {
        
        _titleViewLabel.text = item.itemName;
    }
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
